import request from '@/utils/request'

export interface orderDetailModel {
    id: number,
    orderId: number,
    skuId: number,
    skuName: string,
    imgUrl: string,
    orderPrice: number,
    skuNum: number,
    createTime: string,
    sourceType: string,
    sourceId: number,
    splitTotalAmount: number,
    splitActivityAmount: number,
    splitCouponAmount: number,
    refundStatus: string,
    refundStatusString: string,
    hasStock: null,
    activityRule: null,
    couponInfoList: null
}

export interface orderModel {
    id: number,
    consignee: string,
    consigneeTel: string,
    totalAmount: number,
    orderStatus: string,
    userId: number,
    paymentWay: string,
    deliveryAddress: string,
    orderComment: string,
    outTradeNo: string,
    tradeBody: string,
    createTime: string,
    operateTime: null,
    expireTime: string,
    processStatus: string,
    trackingNo: null,
    parentOrderId: null,
    imgUrl: null,
    provinceId: null,
    activityReduceAmount: null,
    couponAmount: null,
    originalTotalAmount: null,
    feightFee: null,
    feightFeeReduce: null,
    refundableTime: null,
    orderDetailList: orderDetailModel[],
    orderDetailVoList: null,
    orderStatusName: string,
    wareId: null,
    couponInfo: null
}

export interface orderPageModel {
    records: orderModel[],
    total: number,
    size: number,
    current: number,
    searchCount: boolean,
    pages: number
}

export interface orderParams {
    outTradeNo: string,
    consignee: string,
    consigneeTel: string,
    deliveryAddress: string,
    orderStatus: string,
    createTimeBegin: string,
    createTimeEnd: string
}

export default {
    // 获取初始化数据
    getOrderList(page: number, limit: number, params?: orderParams) {
        return request.get<any, orderPageModel>(`/admin/order/${page}/${limit}`, {
            params: params
        })
    },
    // 签收订单
    recieve(orderId: number) {
        return request.get<any, null>(`/admin/order/recieve/${orderId}`)
    }
}